/*************************************************************************
	> File Name: test12.cc
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/09/21 13:23
 ************************************************************************/

#include <iostream>
#include <signal.h>

void handler(int signum)
{
    std::cout << "Child process exit:" << signum << "\nFather pid:" << getpid() << std::endl;
}
int main(int argc, char *argv[])
{
    signal(SIGCHLD, handler);
    if (fork() == 0) {
        std::cout << "Child process pid:" << getpid() << std::endl;
        sleep(100);
        exit(0);
    }
    while (1) {
        sleep(1);
    }
    return 0;
}
